import { WeApp } from '../../../common/common';
import { config } from '../../../etc/config';
import * as __ from '../../../assets/plugins/underscore.js';
import tools from '../../../common/tools';
import httpClient from '../../../common/http-client';
import wxService from '../../../common/wxService';
import { IEnterpriseApply } from '../../../model/user';
import utils from '../../../utils/utils';
import * as wux from '../../../assets/components/wux';
import wxValidate from '../../../common/wxValidate';
import { MlcEnum } from '../../../model/enum';

const app = getApp();
interface VerInfoPageData {
	apply?: IEnterpriseApply
}

interface VerInfoPage extends IPage {
}

class VerInfoPage {
	private steps = [
		{
			text: '填写信息',
			icon: 'http://r.59im.com/wx/icon/company_edit_infor_icon@2x.png'
		},
		{
			text: '上传图片',
			icon: 'http://r.59im.com/wx/icon/company_photo_icon@2x.png'
		},
		{
			text: '等待审核',
			icon: 'http://r.59im.com/wx/icon/company_wait_icon@2x.png'
		},
		{
			text: '认证成功',
			icon: 'http://r.59im.com/wx/icon/company_success_icon@2x.png'
		}
	];

	public data: VerInfoPageData = {
		apply: {}
	}

	loadData() {
		wxService.showLoading();
		return httpClient.get<IEnterpriseApply>(config.user.apply_get)
			.then(res => {
				let sd = {}
				if (res.succeed) {
					if (res.value.imgs) {
						sd['updataFile'] = res.value.imgs.map(item => {
							return {
								url: config.domain + item,
								path: item
							}
						});
					}
					sd['apply'] = res.value;
					this.setData(sd);
				} else {
					utils.showToastErr(res.msg);
				}
			})
			.catch(e => {
			})
	}

	onLoad() {
		this.loadData().then(res=>{			
			wx.hideLoading();
		});
	}
}

Page(new VerInfoPage());
